#pragma once

#include <QWidget>
#include <qobject.h>
#include <QTreeView.h>
#include <qstandarditemmodel.h>
#include <baseFeature.h>
#include <brepFeature.h>
#include <filletFeature.h>
#include <transformFeature.h>
#include <stretchFeature.h>
#include <revolFeature.h>
#include <hollowFeature.h>
#include <QTimer>


class modelSoft;

class historyMananger: public QObject{
	Q_OBJECT
public:
    historyMananger(modelSoft* modelSoft);
	~historyMananger();
	void redo();
	void undo();
	void undoByFeature(BaseFeature* feature);
	Handle(QIVtkSelectionPipeline) redoByFeature(BaseFeature* feature);
	bool getHistorySelect();
	void setHistorySelect(bool select);
	QString splitText(QString str, bool front);


protected:
	void undoCreate(int shapeId);
	Handle(QIVtkSelectionPipeline) redoCreate(BaseFeature* feature);
	void undoBrep(int brepId);
	Handle(QIVtkSelectionPipeline) redoBrep(BrepFeature* feature);
	void undoFillet(int filletId);
	Handle(QIVtkSelectionPipeline) redoFillet(FilletFeature* feature);
	void undoTransform(int transformId);
	Handle(QIVtkSelectionPipeline) redoTransform(TransformFeature* feature);
	void undoStretch(int stretchId);
	Handle(QIVtkSelectionPipeline) redoStretch(StretchFeature* feature);
	void undoRevol(int revolId);
	Handle(QIVtkSelectionPipeline) redoRevol(RevolFeature* feature);
	void undoHollow(int hollowId);
	Handle(QIVtkSelectionPipeline) redoHollow(HollowFeature* feature);
	

protected slots:
	void doubleClickedTree(const QModelIndex& index);
	void clickedTree(const QModelIndex& index);
	void singleClick();



public:
	QStandardItemModel* historyTree;

private:
	QTimer* clickTimer;
	modelSoft* myModelSoft;
	bool historySelect = false;
	bool clicked = false;
	bool highlightClicked = false;
	//0:建模操作 1:Brep 2:stretch 3:hollow 4:fillet 5:revol 6:transform
	int lastOperationType;
	BaseFeature* lastUndoFeature;
	QModelIndex clickedIndex;
};
